function creatPNumber(number) {
    var fomat = '(xxx) xxx-xxx';
    for (var i = 0; i < number.length; i++) {
        fomat = fomat.replace('x', number[i]);
    }
    return fomat;
}
console.log(creatPNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]))